"""
iter函数 - 把可迭代对象变成迭代器

hash码 ---> MD5/SHA1/SHA256 ---> 数字摘要、签名、指纹
"""
import hashlib

hasher = hashlib.md5()
with open('Python-3.9.1.tar.xz', 'rb') as file:
    for data in iter(lambda: file.read(512), b''):
        hasher.update(data)
    print(hasher.hexdigest())

# gen = iter([1, 2, 3, 4, 5])
# print(type(gen))

# hasher = hashlib.md5()
# hasher.update('123456'.encode())
# print(hasher.hexdigest())
#
# hasher = hashlib.md5()
# hasher.update('123457'.encode())
# print(hasher.hexdigest())
